package com.ljl.mvvmdemo.ui.activity

import androidx.recyclerview.widget.LinearLayoutManager
import com.ljl.mvvmdemo.R
import com.ljl.mvvmdemo.databinding.ActivitySecondBinding
import com.ljl.mvvmdemo.ui.adapter.TestAdapter
import com.ljl.mvvmdemo.ui.dialog.TestDialog
import com.ljl.mvvmdemo.viewmodel.SecondViewModel

/**
 * created by luojialun on 2024/4/10
 */
class SecondActivity : BaseActivity<ActivitySecondBinding, SecondViewModel>() {

    override fun getLayoutId(): Int = R.layout.activity_second

    override fun initView() {
        viewModel.showTestDialogLiveData.observe(this, { showTestDialogLiveData ->
            if (showTestDialogLiveData) {
                val testDialog = TestDialog()
                testDialog.show(supportFragmentManager, "TestDialog")
            }
        })

        binding.rv.layoutManager = LinearLayoutManager(this)
        val testAdapter = TestAdapter()
        val contentList = mutableListOf<String>()
        contentList.add("111")
        contentList.add("222")
        testAdapter.setNewInstance(contentList)

        binding.rv.adapter = testAdapter
    }

}